#include <iostream>
#include <vector>
#include <gtest\gtest.h>
using namespace std;

class obj
{
public:
	obj() 
	{
		msObjCreateCount++;
		cout << ">> create obj " << endl;
	}
	obj(const obj& other) 
	{
		msObjCopyCount++;
		cout << ">> copy create obj " << endl; 
	}
	static size_t GetCreateCount() { return msObjCreateCount; }
	static size_t GetCopyCount() { return msObjCopyCount; }
private:
	static size_t msObjCreateCount;
	static size_t msObjCopyCount;
};

size_t obj::msObjCreateCount = 0;
size_t obj::msObjCopyCount = 0;
vector<obj> foo()
{
	vector<obj> c;
	c.push_back(obj());

	cout << "---- exit foo ----" << endl;
	return c;
}

TEST(RValueTest, Copy)
{
	vector<obj> k;
	k = foo();// In C++11, = using move semantics so that no need to copy 2 times 
	EXPECT_EQ(1, obj::GetCreateCount());
	EXPECT_EQ(1, obj::GetCopyCount());
	getchar();
}